import { defineStore } from 'pinia';

export default defineStore('editor', {
  state: () => {
    return {
      state: {
        ruler: false,
        width: 1920,
        height: 800,
      },
    };
  },
  // getters 计算属性
  getters: {},
  // actions 修改数据的方法
  actions: {
    toggleRuler() {
      this.state.ruler = !this.state.ruler;
    },
    setData(data) {
      this.state.width = data.width;
      this.state.height = data.height;
    },
  },
  // 数据持久化 - 默认全部sessionStorage
  persist: {
    enabled: true,
  },
});
